/**
 * @author LKQ
 * @date 2022/3/3 13:38
 * @description 动态规划，从后往前，计算完成i及之后题目的最大分数
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] qu = {{21,5},{92,3},{74,2},{39,4}, {58,2}, {5,5}, {49,4}, {65,3}};
        solution.mostPoints(qu);
    }
    public long mostPoints(int[][] questions) {
        int m = questions.length;
        long[] dp = new long[m + 1];
        for (int i = m - 1; i >= 0; i--) {
            dp[i] = Math.max(dp[i + 1], questions[i][0] + dp[Math.min(m, i + questions[i][1] + 1)]);
        }
        return dp[0];
    }
}
